﻿using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace MapEditor.Tiles
{
    class RegularTile : Tile
    {
        public const int Identifier = 1;

        public const int tileSize = 32;


        public int type
        {
            get;
            set;
        }

        public Rectangle rectangle
        {
            get;
            set;
        }

        public RegularTile(int type, int tileX, int tileY, bool showGrid)
        {
           if (showGrid)
            {
                switch (type)
                {
                    case 8: case 29: case 30: case 31: 
                        this.rectangle = new Rectangle(tileX * tileSize, tileY * tileSize, tileSize, tileSize *2);
                        break;
                    case 19:
                        this.rectangle = new Rectangle(tileX * tileSize, tileY * tileSize, tileSize * 3, tileSize);
                        break;
                    case 20: case 32: case 33: case 34:
                        this.rectangle = new Rectangle(tileX * tileSize, tileY * tileSize, tileSize * 2, tileSize);
                        break;
                    default:
                        this.rectangle = new Rectangle(tileX * tileSize, tileY * tileSize, tileSize, tileSize);
                        break;
                }
            }
            else
            {
                switch (type)
                {
                    case 8:
                    case 29:
                    case 30:
                    case 31:
                        this.rectangle = new Rectangle(tileX, tileY, tileSize, tileSize * 2);
                        break;
                    case 19:
                        this.rectangle = new Rectangle(tileX, tileY, tileSize * 3, tileSize);
                        break;
                    case 20:
                    case 32:
                    case 33:
                    case 34:
                        this.rectangle = new Rectangle(tileX, tileY, tileSize * 2, tileSize);
                        break;
                    default:
                        this.rectangle = new Rectangle(tileX, tileY, tileSize, tileSize);
                        break;
                }
                
            }

            this.type = type;
        }

            
       
        public int Value
        {
            get
            {
                return (rectangle.Y / rectangle.Height + rectangle.X / rectangle.Width) + 1;
            }
        }

        public void Draw(SpriteBatch spriteBatch, Rectangle destination, Texture2D tileset)
        {
            spriteBatch.Draw(tileset, destination, Color.White);
        }
    }
}
